/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package compilador.analisador;

/**
 *
 * @author Gustavo
 */
public class Simbolos {

    public Simbolos()
    {

    }

    public int compareToSimbolo(String x)
    {
        if (x.compareTo("program")==0) return 1;
        if (x.compareTo("var")==0) return 1;
        if (x.compareTo("begin")==0) return 1;
        if (x.compareTo("end.")==0) return 1;
        if (x.compareTo("boolean")==0) return 1;
        if (x.compareTo("integer")==0) return 1;
        if (x.compareTo("real")==0) return 1;
        if (x.compareTo("string")==0) return 1;
        return 0;
    }

     public int compareToInteiro(String x)
    {
        int l=x.length();
        int k=0;
        for (int j=0;j<l;j++)
        {
            if ((x.charAt(j)=='0') || (x.charAt(j)=='1') || (x.charAt(j)=='2') || (x.charAt(j)=='3') || (x.charAt(j)=='4') || (x.charAt(j)=='5') || (x.charAt(j)=='6') ||
            (x.charAt(j)=='7') || (x.charAt(j)=='8') || (x.charAt(j)=='9'))
                k=1; else k=0;
            if (k==0) break;
        }
        return k;
    }

     public int compareToOpSep(String x)
    {
        int l=x.length();
        int k;
            if ((x.charAt(0)==';') || (x.charAt(0)=='(') || (x.charAt(0)==')') || (x.charAt(0)==',') || (x.charAt(0)=='+') || (x.charAt(0)=='-') || (x.charAt(0)=='*') ||
          (x.charAt(0)=='/') || (x.charAt(0)==':'))
                k=1; 
            else k=0;
        return k;
    }

     public int compareToIdentificador(String x)
    {

        return 1;
    }

     public int compareToPalavra(String x)
    {
        int l=x.length();
        int k;
            if ((x.charAt(0)=='\'') && (x.charAt(l-1)=='\''))
                k=1;
            else k=0;
        return k;
    }

     public int compareToComando(String x)
    {
        if (x.compareTo("writeln")==0) return 1;
        if (x.compareTo("readln")==0) return 1;
        if (x.compareTo("if")==0) return 1;
        if (x.compareTo("while")==0) return 1;
        if (x.compareTo("for")==0) return 1;
        if (x.compareTo(":=")==0) return 1;
        return 0;
    }
}
